#ifndef EVENTMANAGER_H
#define EVENTMANAGER_H

#include "../Config/Export.h"
#include "../Utilities/Singleton.h"
#include "GL/glfw.h"

#define NBKEYS 1024
#define NBMOUSEBUTTONS 10

namespace epix {

class SHARED EventManager : public Singleton<EventManager>
{
    MAKE_SINGLETON(EventManager)

    public:

        void init(bool keyRepeat = true, bool stickykeys = true, bool stickyMouseButtons = true);

        void getEvent();

        bool isKeyDownOnce(int key);
        bool isKeyDown(int key) const;

        bool isMouseButtonUp(int button) const;

        int getMouseX() const;
        int getMouseY()const;
        int getRelMouseX() const;
        int getRelMouseY() const;

        bool quit() const;

        void eventKeyCB(int key, int action);
        void eventMouseCB(int x, int y);
        void eventMouseButtonCB(int button, int action);

    private:

        int _keyDown[NBKEYS], _keyOnce[NBKEYS];
        int _mouseButton[NBMOUSEBUTTONS];

        int _mouseX, _mouseY, _oldMouseX, _oldMouseY, _relX, _relY;

        bool _quit;
};

}

#endif
